package com.tdkj.service.risevalue.impl;

import java.math.BigDecimal;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.tdkj.dao.risevalue.IBeanPlateQuotationCustomDao;
import com.tdkj.model.risevalue.BeanPlateQuotation;
import com.tdkj.model.risevalue.BeanPlateQuotationCustom;
import com.tdkj.service.BaseService;
import com.tdkj.service.risevalue.IBeanPlateQuotationCustomService;
            
@Component
public class BeanPlateQuotationCustomServiceImpl extends BaseService implements IBeanPlateQuotationCustomService{
	
	private  IBeanPlateQuotationCustomDao beanPlateQuotationPriceDao;
	                              
	@Resource
	public void setBeanPlateQuotationPriceDao(IBeanPlateQuotationCustomDao beanPlateQuotationPriceDao) {
		this.beanPlateQuotationPriceDao = beanPlateQuotationPriceDao;
	}

	public IBeanPlateQuotationCustomDao getBeanPlateQuotationPriceDao() {
		return beanPlateQuotationPriceDao;
	}

	@Override
	public void add(BeanPlateQuotationCustom bean) {
		beanPlateQuotationPriceDao.save(bean);
	}

	@Override
	public void delete(Long id) {
		BeanPlateQuotationCustom bean = beanPlateQuotationPriceDao.findById(id, BeanPlateQuotationCustom.class);
		beanPlateQuotationPriceDao.delete(bean);
	}

	@Override
	public BeanPlateQuotationCustom get(Long id) {
		BeanPlateQuotationCustom bean = beanPlateQuotationPriceDao.findById(id, BeanPlateQuotationCustom.class);
		bean.getPlate();
		return bean;
	}

	@Override
	public List<BeanPlateQuotationCustom> getAll() {
		return beanPlateQuotationPriceDao.findAll(BeanPlateQuotationCustom.class);
	}

	@Override
	public void update(Long id, BigDecimal timeLimitAmount, String timeLimitUnit, BigDecimal price, String unit) {
		BeanPlateQuotationCustom bean = beanPlateQuotationPriceDao.findById(id, BeanPlateQuotationCustom.class);
		bean.setTimeLimitAmount(timeLimitAmount);
		bean.setTimeLimitUnit(timeLimitUnit);
		bean.setPrice(price);
		bean.setUnit(unit);
	}

	@Override
	public List<BeanPlateQuotationCustom> getByPlateId(Long plateId) {
		BeanPlateQuotation plate = beanPlateQuotationPriceDao.findById(plateId, BeanPlateQuotation.class);
		return plate.getCustoms();
	}

	@Override
	public void add(BigDecimal timeLimitAmount, String timeLimitUnit, BigDecimal price, String unit, Long plateId) {
		BeanPlateQuotation plate = beanPlateQuotationPriceDao.findById(plateId, BeanPlateQuotation.class);
		
		BeanPlateQuotationCustom bean = new BeanPlateQuotationCustom();
		bean.setPrice(price);
		bean.setTimeLimitAmount(timeLimitAmount);
		bean.setTimeLimitUnit(timeLimitUnit);
		bean.setPlate(plate);
		bean.setUnit(unit);
		
		beanPlateQuotationPriceDao.save(bean);
		
	}


	
}
